// JavaScript Document


//获取样式
function getStyle(obj,attr){
	if(obj.currentStyle){
		return obj.currentStyle[attr];
		}
	else{ 
		return getComputedStyle(obj,false)[attr];
		}
	}



//运动
var timer=null;
function move(obj,json,fn){
	clearInterval(obj.timer); 
	obj.timer = setInterval(function(){ 
		var bstop=true;
		for(var attr in json){		
			var cur=0;
			if(attr=='opacity'){
				cur=Math.round(getStyle(obj,attr)*100);
				}
			else{
				cur=parseInt(getStyle(obj,attr));
				}
			
			
			var speed=(json[attr]-cur)/5;
			speed=speed>0?Math.ceil(speed):Math.floor(speed);
			
			if(cur!=json[attr]){
				bstop=false;
				}
			
			if(attr=='opacity'){
				obj.style.opacity=(cur+speed)/100;
				obj.style.filter='alpha(opacity='+(cur+speed)+')';
				}
			else{
				obj.style[attr]=cur+speed+'px';
				}	
			}
		if(bstop){
			clearInterval(obj.timer);
			fn&&fn();
			}
		
		},30);
}
	
//获取类
function getClass(parent,sclass){
	parent=parent||document;
	var aEle=parent.getElementsByTagName('*');
	var arr=[];
	var i=0;
	var reg=new RegExp('\\b'+sclass+'\\b','i');
	for(i=0;i<aEle.length;i++){
			if(reg.test(aEle[i].className)){
				arr.push(aEle[i]);
				}
		}
	return arr;
	
	}